<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backTo()"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">系统设置</view>
		</view>
		<view class="bg_box">
			<image class="bg01" src="/static/bg05.png" mode="widthFix"></image>
			<view class="bg_content">
				<view class="details_box">
					<view class="details_title">账号设置</view>
					<view class="list" :data-url="'/pages/personalcenter/settings/profile'" @click="gotopage">
						<view class="icon iconfont icon-gerenziliao"></view>
						<view class="name">个人资料</view>
						<view class="arrow iconfont icon-xiangyou1"></view>
					</view>
					<view class="list" :data-url="'/pages/personalcenter/standing'" @click="gotopage">
						<view class="icon iconfont icon-anquanhegui1"></view>
						<view class="name">实名认证</view>
						<view class="arrow iconfont icon-xiangyou1"></view>
					</view>
					<!-- 	<view class="list" :data-url="'/pages/personalcenter/settings/cipher'" @click="gotopage">
						<view class="icon iconfont icon-xiugaimima"></view>
						<view class="name">修改密码</view>
						<view class="arrow iconfont icon-xiangyou1"></view>
					</view> -->
				</view>

				<view class="details_box">
					<view class="details_title">系统设置</view>
					<view class="list">
						<view class="icon iconfont icon-fuyuetixing"></view>
						<view class="name">覆约提醒</view>
						<switch checked color="#FC5D20" @change="remindChange" />
					</view>
					<view class="list" @click="clear_cache()">
						<view class="icon iconfont icon-qinglihuancun"></view>
						<view class="name">清理缓存</view>
						<view class="text">{{size}}KB</view>
					</view>
					<view class="list" :data-url="'/pages/personalcenter/settings/us'" @click="gotopage">
						<view class="icon iconfont icon-guanyuwomen"></view>
						<view class="name">关于我们</view>
						<view class="arrow iconfont icon-xiangyou1"></view>
					</view>
					<!-- 	<view class="list" :data-url="'/pages/public/login'" @click="gotopage">
						<view class="icon iconfont icon-tuichudenglu"></view>
						<view class="name">退出登录</view>
						<view class="arrow iconfont icon-xiangyou1"></view>
					</view> -->
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				page: 1,
				scrrol: false,
				info: '',
				size : '',

			}
		},
		onLoad() {
            let storageInfo = uni.getStorageInfoSync();
			console.log(storageInfo)
            let size = storageInfo.currentSize;
			this.size = size;
		},
		methods: {
			...mapMutations(['logout']),
			
			remindChange(e) {
				// 此处用法为在js中调用，需要写uni.$u.debounce()
				let flag = e.detail.value?1:0;
				uni.showLoading({
					title:'处理中,请稍后'
				})
				uni.$u.debounce(()=>{
					this.real_remind(flag)
				}, 1200)
			},
			real_remind(flag) {
				let url = this.site_url + 'api/auth/loans/change_notice?remind='+flag;
				this.areq(url).then(res=>{
					uni.hideLoading();
					if(res.code == 1){
						let msg = flag ? '已启用提醒':'已取消提醒';
						this.showMsg(msg);
					}
				})
			},
			clear_cache() {
				uni.showModal({
					title: '清理提示',
					content: '确定清理吗？此操作将退出登录',
					success: (rs) => {
						if (rs.confirm) {

							uni.showLoading({
								title: '正在清除缓存'
							});
							setTimeout(() => {
								uni.clearStorageSync();
								uni.hideLoading();

								uni.showToast({
									title: '缓存已清除',
									icon: 'success'
								});
								this.logout();
								setTimeout(() => {
									this.$r('/page/personalcenter/personalcenter', 'rel');
								}, 800)

							}, 800)

						} else if (rs.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				this.$r(url);
			},

		},
		onPageScroll: function(Object) {
			if (Object.scrollTop > 28) {
				this.scrrol = true;
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
			}
		},

	}
</script>

<style>
	.header {
		background-color: transparent !important;
	}

	.header .text {
		background-color: transparent !important;
		color: #333 !important;
	}

	.scrrolHeader {
		background-color: #F9E9E3 !important;
	}

	.bg_box {
		width: 100%;
		position: relative;
	}

	.bg_box .bg01 {
		width: 100%;
	}

	.bg_box .bg_content {
		width: 92%;
		position: absolute;
		left: calc(50% - 46%);
		top: calc(13.5vw + var(--status-bar-height));
		z-index: 98;
	}

	.details_box {
		width: 100%;
		margin-top: 4%;
		background-color: #fff;
		padding: 5vw 4%;
		border-radius: 3vw;
	}

	.details_boxNo {
		padding: 0vw 4%;
	}

	.details_box .details_title {
		font-size: 4.2vw;
		color: #333;
		font-weight: bold;
		margin-bottom: 5vw;
	}

	.details_box .input_box {
		width: 100%;
		display: flex;
		align-items: center;
		border-bottom: 2px solid #FC5D20;
		height: 15vw;
	}

	.details_box .input_box .m {
		font-size: 4vw;
		color: #333;
		margin-right: 1vw;
		font-weight: bold;
		margin-top: 2vw;
	}

	.details_box .input_box input {
		font-size: 7vw;
		color: #333;
		flex: 1;
		font-weight: bold;
	}

	.details_box .list {
		width: 100%;
		padding: 5vw 0;
		border-bottom: 1px solid #F3F3F3;
		display: flex;
		align-items: center;
	}

	.details_box .list .icon {
		font-size: 5vw;
		color: #333;
		margin-right: 3vw;
	}

	.details_box .list .name {
		font-size: 4.2vw;
		font-weight: bold;
		color: #333;
		flex: 1;
	}

	.details_box .list .text {
		flex: 1;
		font-size: 3.5vw;
		color: #999999;
		margin-right: 1vw;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.details_box .list .text .i {
		width: 5vw;
		margin-right: 1vw;
	}

	.details_box .list .text .i image {
		width: 100%;
	}

	.details_box .list input {
		flex: 1;
		font-size: 3.5vw;
		color: #333;
		margin-right: 3vw;
		text-align: right;
		font-weight: bold;
	}

	.details_box .list .arrow {
		font-size: 3.5vw;
		color: #CCCDD4;
	}

	.details_box .list switch {
		transform: scale(.7, .7);
	}
</style>